package com.example.tool.bean.wcaiexcel;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 企业微信智能表格字段类型枚举
 */
@Getter
@AllArgsConstructor
public enum WeChatFieldType {
    FIELD_TYPE_TEXT("FIELD_TYPE_TEXT", "文本"),
    FIELD_TYPE_NUMBER("FIELD_TYPE_NUMBER", "数字"),
    FIELD_TYPE_CHECKBOX("FIELD_TYPE_CHECKBOX", "复选框"),
    FIELD_TYPE_DATE_TIME("FIELD_TYPE_DATE_TIME", "日期"),
    FIELD_TYPE_IMAGE("FIELD_TYPE_IMAGE", "图片"),
    FIELD_TYPE_ATTACHMENT("FIELD_TYPE_ATTACHMENT", "文件"),
    FIELD_TYPE_USER("FIELD_TYPE_USER", "成员"),
    FIELD_TYPE_URL("FIELD_TYPE_URL", "超链接"),
    FIELD_TYPE_SELECT("FIELD_TYPE_SELECT", "多选"),
    FIELD_TYPE_CREATED_USER("FIELD_TYPE_CREATED_USER", "创建人"),
    FIELD_TYPE_MODIFIED_USER("FIELD_TYPE_MODIFIED_USER", "最后编辑人"),
    FIELD_TYPE_CREATED_TIME("FIELD_TYPE_CREATED_TIME", "创建时间"),
    FIELD_TYPE_MODIFIED_TIME("FIELD_TYPE_MODIFIED_TIME", "最后编辑时间"),
    FIELD_TYPE_PROGRESS("FIELD_TYPE_PROGRESS", "进度"),
    FIELD_TYPE_PHONE_NUMBER("FIELD_TYPE_PHONE_NUMBER", "电话"),
    FIELD_TYPE_EMAIL("FIELD_TYPE_EMAIL", "邮件"),
    FIELD_TYPE_SINGLE_SELECT("FIELD_TYPE_SINGLE_SELECT", "单选"),
    FIELD_TYPE_REFERENCE("FIELD_TYPE_REFERENCE", "关联"),
    FIELD_TYPE_LOCATION("FIELD_TYPE_LOCATION", "地理位置"),
    FIELD_TYPE_FORMULA("FIELD_TYPE_FORMULA", "公式"),
    FIELD_TYPE_CURRENCY("FIELD_TYPE_CURRENCY", "货币"),
    FIELD_TYPE_WWGROUP("FIELD_TYPE_WWGROUP", "群"),
    FIELD_TYPE_AUTONUMBER("FIELD_TYPE_AUTONUMBER", "自动编号"),
    FIELD_TYPE_PERCENTAGE("FIELD_TYPE_PERCENTAGE", "百分数"),
    FIELD_TYPE_BARCODE("FIELD_TYPE_BARCODE", "条码");

    private final String code;
    private final String description;

    /**
     * 根据code获取枚举实例
     */
    public static WeChatFieldType fromCode(String code) {
        for (WeChatFieldType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的字段类型: " + code);
    }

    @Override
    public String toString() {
        return code;
    }
}
